var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    }; Object.defineProperty(o, "__esModule", { value: !0 });
var a = e("BaseModuleUI"),
    n = e("AssetsManager"),
    i = e("CommonHelper"),
    r = e("RoleSoldierInfo"),
    s = e("sdkConfig"),
    l = cc._decorator,
    _ = l.ccclass,
    c = l.property,
    d = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.skill_type_view = null),
                (t.hero_node_my = null),
                (t.hero_ske_0 = null),
                (t.hero_my_effects = null),
                (t.fill_node = null),
                (t.hero_node_target = null),
                (t.hero_ske_1 = null),
                (t.hero_other_effects = null),
                (t.be_hit_node = null),
                t
            );
        }
        return (
            nn(t, e),
            (t.prototype.initView = function () {
                e.prototype.initView.call(this), this.showSkillTypeView(), this.chooseSkillType(0);
            }),
            (t.prototype.OnClick = function (t) {
                e.prototype.OnClick.call(this, t);
                var o = t.node.name;
                switch (o) {
                    case "skill_node_0":
                    case "skill_node_1":
                    case "skill_node_2":
                    case "skill_node_3":
                    case "skill_node_4":
                    case "skill_node_5":
                        var a = Number(i.default.getNameType(o, "skill_node_"));
                        this.chooseSkillType(a);
                }
            }),
            (t.prototype.showSkillTypeView = function () {
                for (var e = 0; e < 6; e++) {
                    var t = this.skill_type_view.children[e],
                        o = r.default.Player_Skill_Info[e];
                    (t.children[1].getComponent(cc.Sprite).spriteFrame = n.default
                        .getInstance()
                        .getPlayerSkillFrame(
                            "skill_" + (s.default.platform == s.EPlatform.TikTok ? "dy_" : "") + (e + 1)
                        )),
                        (t.children[2].getComponent(cc.Label).string = o.name),
                        (t.children[3].getComponent(cc.Label).string = o.skill_info),
                        (t.children[4].getComponent(cc.Label).string = "冷却时间：" + o.cooling + "秒");
                }
            }),
            (t.prototype.chooseSkillType = function (e) {
                for (var t = this, o = 0; o < this.skill_type_view.childrenCount; o++)
                    this.skill_type_view.children[o].children[0].active = o == e;
                if (
                    (this.unscheduleAllCallbacks(),
                        this.hero_node_my.stopAllActions(),
                        (this.hero_node_target.active = -1 == [0, 1, 5].indexOf(e)),
                        (this.hero_node_my.active = !0),
                        this.hero_node_my.setPosition(cc.v2(300, 30)),
                        (this.hero_node_my.children[0].active = 0 == e),
                        (this.hero_my_effects.node.active = !1),
                        (this.fill_node.active = !1),
                        (this.hero_other_effects.node.active = !1),
                        (this.hero_other_effects.node.scale = 1),
                        (this.hero_other_effects.node.y = -80),
                        0 == e)
                ) {
                    this.hero_ske_0.setAnimation(0, "run", !0);
                    var a = cc
                        .tween(this.hero_node_my)
                        .call(function () {
                            t.hero_node_my.setPosition(cc.v2(100, 30));
                        })
                        .to(1.5, { position: cc.v2(600, 30) })
                        .call(function () {
                            a.start();
                        });
                    a.start();
                } else if (1 == e)
                    (this.hero_my_effects.node.active = !0),
                        this.hero_node_my.setPosition(cc.v2(400, 30)),
                        this.hero_ske_0.setAnimation(0, "battle_idle", !0),
                        this.hero_my_effects.setAnimation(0, "zl", !0);
                else if (2 == e)
                    this.hero_ske_0.setAnimation(0, "battle_idle", !0),
                        (this.fill_node.active = !0),
                        this.fill_node.setPosition(cc.v2(300, 55)),
                        cc
                            .tween(this.fill_node)
                            .to(0.3, { position: this.hero_node_target.getPosition() })
                            .call(function () {
                                (t.fill_node.active = !1),
                                    (t.hero_other_effects.node.active = !0),
                                    t.hero_other_effects.setAnimation(0, "dr", !0),
                                    t.showTargetHit(t.hero_node_target, 50),
                                    t.schedule(
                                        function () {
                                            t.showTargetHit(t.hero_node_target, 50);
                                        },
                                        0.5,
                                        2
                                    ),
                                    t.scheduleOnce(function () {
                                        t.scheduleOnce(function () {
                                            t.chooseSkillType(e);
                                        }, 1);
                                    }, 2);
                            })
                            .start();
                else if (3 == e)
                    this.hero_ske_0.setAnimation(0, "battle_idle", !0),
                        (this.fill_node.active = !0),
                        this.fill_node.setPosition(cc.v2(300, 55)),
                        cc
                            .tween(this.fill_node)
                            .to(0.3, { position: this.hero_node_target.getPosition() })
                            .call(function () {
                                (t.fill_node.active = !1),
                                    (t.hero_other_effects.node.active = !0),
                                    t.hero_other_effects.setAnimation(0, "zz", !0),
                                    t.scheduleOnce(function () {
                                        t.scheduleOnce(function () {
                                            t.chooseSkillType(e);
                                        }, 1);
                                    }, 5);
                            })
                            .start();
                else if (4 == e)
                    this.hero_ske_0.setAnimation(0, "battle_idle", !0),
                        (this.fill_node.active = !0),
                        this.fill_node.setPosition(cc.v2(300, 55)),
                        cc
                            .tween(this.fill_node)
                            .to(0.3, { position: this.hero_node_target.getPosition() })
                            .call(function () {
                                (t.fill_node.active = !1),
                                    (t.hero_other_effects.node.active = !0),
                                    (t.hero_other_effects.node.y = 20),
                                    (t.hero_other_effects.node.scale = 2),
                                    t.hero_other_effects.setAnimation(0, "zs", !1),
                                    t.scheduleOnce(function () {
                                        t.showTargetHit(t.hero_node_target, 100),
                                            t.scheduleOnce(function () {
                                                t.chooseSkillType(e);
                                            }, 1.2);
                                    }, 0.5);
                            })
                            .start();
                else if (5 == e) {
                    var n = cc
                        .tween(this.hero_node_my)
                        .call(function () {
                            t.hero_ske_0.setAnimation(0, "run", !0), t.hero_node_my.setPosition(cc.v2(100, 30));
                        })
                        .to(0.5, { position: cc.v2(200, 30) })
                        .call(function () {
                            t.hero_node_my.opacity = 20;
                        })
                        .by(0.1, { position: cc.v2(300, 0) })
                        .call(function () {
                            t.hero_node_my.opacity = 255;
                        })
                        .to(1, { position: cc.v2(700, 30) })
                        .delay(0.5)
                        .call(function () {
                            n.start();
                        });
                    n.start();
                }
            }),
            (t.prototype.showTargetHit = function (e, t) {
                var o = cc.instantiate(this.be_hit_node);
                (o.active = !0),
                    (o.getComponent(cc.Label).string = "" + t),
                    o.setPosition(cc.v2(0, 60)),
                    (o.scale = 0.6),
                    (o.opacity = 255),
                    cc
                        .tween(o)
                        .by(1, { position: cc.v2(0, 120), opacity: 60, scale: 1 })
                        .call(function () {
                            o.destroy();
                        })
                        .start(),
                    e.addChild(o);
            }),
            oo([c(cc.Node)], t.prototype, "skill_type_view", void 0),
            oo([c(cc.Node)], t.prototype, "hero_node_my", void 0),
            oo([c(sp.Skeleton)], t.prototype, "hero_ske_0", void 0),
            oo([c(sp.Skeleton)], t.prototype, "hero_my_effects", void 0),
            oo([c(cc.Node)], t.prototype, "fill_node", void 0),
            oo([c(cc.Node)], t.prototype, "hero_node_target", void 0),
            oo([c(sp.Skeleton)], t.prototype, "hero_ske_1", void 0),
            oo([c(sp.Skeleton)], t.prototype, "hero_other_effects", void 0),
            oo([c(cc.Node)], t.prototype, "be_hit_node", void 0),
            oo([_], t)
        );
    })(a.default);
o.default = d;
